<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/easyui/themes/default/easyui.css">
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/easyui/themes/icon.css">
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/inputfile.css">
    <script type="text/javascript" src="${pageContext.request.contextPath}/easyui/jquery.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/easyui/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/easyui/locale/easyui-lang-zh_CN.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/easyui/datagrid-detailview.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/template-native.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/ueditor/ueditor.config.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/ueditor/ueditor.all.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/ueditor/lang/zh-cn/zh-cn.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/other.js"></script>
    <script type="text/javascript">
        let editor;
        $(function () {
            editor = UE.getEditor('editor', {
                theme: "default", //皮肤
                lang: 'zh-cn', //语言
                allowDivTransToP: false,
                toolbars: [
                    [
                        //自定义的工具栏，自定义增减
                        'undo', //撤销
                        'redo', //重做
                        'bold', //加粗
                        'indent', //首行缩进
                        'italic', //斜体
                        'underline', //下划线
                        'strikethrough', //删除线
                        'subscript', //下标
                        'fontborder', //字符边框
                        'superscript', //上标
                        'formatmatch', //格式刷
                        'pasteplain', //纯文本粘贴模式
                        'selectall', //全选
                        'preview', //预览
                        'horizontal', //分隔线
                        'removeformat', //清除格式
                        'time', //时间
                        'date', //日期
                        'inserttitle', //插入标题
                        'cleardoc', //清空文档
                        'fontfamily', //字体
                        'fontsize', //字号
                        'paragraph', //段落格式
                        'link', //超链接
                        'spechars', //特殊字符
                        'searchreplace', //查询替换
                        'justifyleft', //居左对齐
                        'justifyright', //居右对齐
                        'justifycenter', //居中对齐
                        'justifyjustify', //两端对齐
                        'inserttable',
                        'deletetable',
                        'forecolor', //字体颜色
                        'insertorderedlist', //有序列表
                        'insertunorderedlist', //无序列表
                        'fullscreen', //全屏
                        'directionalityltr', //从左向右输入
                        'directionalityrtl', //从右向左输入
                        'rowspacingtop', //段前距
                        'rowspacingbottom', //段后距
                        'imagenone', //默认
                        'imageleft', //左浮动
                        'imageright', //右浮动
                        'imagecenter', //居中
                        'lineheight', //行间距
                        'edittip ', //编辑提示
                        'customstyle', //自定义标题
                        'autotypeset', //自动排版
                        'simpleupload', //单图上传
                        'insertvideo' //视频
                    ]
                ]
            });
            
            editor.addListener("ready", function () {
                
            });

        });

        function changeHeader(obj) {
            var file = obj.files[0];
            var url = window.URL.createObjectURL(file);
            $("#head").attr("src", url);

        }

        function addLoop(){

            let formdata = new FormData($("#loopForm")[0]);
            formdata.append("content",editor.getContent());
            console.log(editor.getContent());
            $.ajax({
                url:"${pageContext.request.contextPath}/loop/addloop",
                type:"POST",
                data:formdata,
                dataType:"json",
                cache: false,
                processData: false,
                contentType: false,
                success: function (data) {
                    // MaskUtil.unmask();
                    // $("#dd_article").dialog();
                    // $('#looplist').datagrid("reload"); //刷新页面
                    // alter("添加成功");
                    alert("添加成功")
                },error:function(data){
                    MaskUtil.unmask();
                    $.messager.alert('提示',data.msg,'error');
                    $("#dd_article").dialog();
                }
            });
        }

    </script>
</head>
<body class="easyui-layout" style="width:100%;height:100%;margin:5px auto;">
    <input type="hidden" id="id" />

    <div data-options="region:'south',split:false" style="width:43%;height:70%;">
        <div id="editor" style="width:99%;height:70%;margin:0 auto;"></div>
    </div>

    <form id="loopForm">
        <div data-options="region:'west',split:false" style="width:40%;height: 130px;">
            <table>
                <tr>
                    <td valign="top">
                        <a href="javascript:;" class="file">选择封面图片
                            <input type="file" id="imgurl" name="file" onchange="changeHeader(this);">
                        </a>
                    </td>
                    <td>
                        <img src="images/zwtp.png" id="head" style="width: 130px;height: 120px;" />
                    </td>
                </tr>
            </table>
        </div>
        <div data-options="region:'center',split:false" style="width:60%;height: 130px;">
            <div id="modeltypeinfo">
                <div style="margin:50px;" name="mrows" id="mrows_1">
                    <input class="easyui-numberbox" style="width:400px; height: 30px;"
                        data-options="min:0,precision:2,label:'标 题:',labelWidth:60" id="p_1" name="title">
                </div>
            </div>
        </div>
    </form>
</body>

</html>